<?php

class Control_License extends QUI_Control_Abstract
{
    function render()
    {
        $licenses = License::find()->order('title ASC')->getAll();
        $text_element = $this->_extract('text_element');

        $out = "<select {$this->_printIdAndName()} {$this->_printAttrs()} onchange=\"document.getElementById('{$text_element}').className = (this.value != 'other') ? 'hidden' : '';\">\n";
        foreach ($licenses as $license)
        {
            $out .= "<option value=\"{$license->id()}\">";
            $out .= h($license->title);
            $out .= "</option>\n";
        }
        $out .= "</select>\n\n";

        return $out;
    }
}

